jQuery.noConflict();

define(["jQuery.ui", "JavaScript.Lang", "WhiteLabel.lateralMenu"], function(jQuery){
     
    function initMenu() {
        jQuery('#menu ul ul').hide();
        jQuery("#menu .active").parents("li").children("ul").show();
        jQuery('#menu ul li').click(function(event) {
            jQuery(this).parent().find("ul").slideUp('fast');
            jQuery(this).parent().find("li").children("a").removeClass("active");
            jQuery(this).find("ul").slideToggle('fast');
            //Avoid submenus from having class 'current' before navigation
            if(jQuery(this).find("ul").length > 0){
                jQuery(this).children("a").toggleClass("active");
            }
            //Avoid submenus from moving before navigation
            event.stopPropagation();
        });
    }

    function beforeSend(){
        jQuery(".ajaxified").html("Un momento por favor...");
    }
    
    function requireIfNeeded(selector, module, functionName, options){
        if(jQuery(selector).length > 0){
            require([module], function(jQuery){
                jQuery(selector)[functionName](options);
            });
        }
    }

    jQuery(document).ready(function($) {
        
        $.datepicker.regional['es'] = {
		closeText: 'Cerrar',
		prevText: '&#x3C;Ant',
		nextText: 'Sig&#x3E;',
		currentText: 'Hoy',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
		dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['es']);

        initMenu(); // Initialize the menu!
        $(".alert").click(function (){
            $(this).hide();
        });

        $('#dialog').dialog({
            autoOpen: false,
            width: 650,
            buttons: {
                "Enviar": function() {
                    $(this).dialog("close");
                },
                "Cancelar": function() {
                    $(this).dialog("close");
                }
            }
        }); // Default dialog. Each should have it's own instance.
			
        $('.dialog_link').click(function(){
            $('#dialog').dialog('open');
            return false;
        }); // Toggle dialog
	
        $('.notification').hover(function() {
            $(this).css('cursor','pointer');
        }, function() {
            $(this).css('cursor','auto');
        }); // Close notifications
			
        $('.checkall').change(function(){
            $(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));
        }); // Top checkbox in a table will select all other checkboxes in a specified column
			
        $('.notification span').click(function() {
            $(this).parents('.notification').fadeOut(800);
        }); // Close notifications on clicking the X button
			
			
        $('.fade_hover').hover(
            function() {
                $(this).stop().animate({
                    opacity:0.6
                },200);
            },
            function() {
                $(this).stop().animate({
                    opacity:1
                },200);
            }
            ); // The fade function
			
        $(".tabs").tabs(); // Enable tabs on all '.tabs' classes
	
        $( ".datepicker" ).datepicker({
            yearRange:"c-50:c+2",
            dateFormat:"dd/mm/yy",
            changeMonth: true,
            changeYear: true
        });
				
        // Slider
        $(".slider").slider({
            range: true,
            values: [20, 70]
        });

        // Progressbar
        $(".progressbar").progressbar({
            value: 40
        });

        $("#sombreadoAcademico").tabs({
            selected:2
        });
    
        requireIfNeeded(".form-validate", "WhiteLabel.validate", "validate");
        requireIfNeeded(".breadcrumb", "WhiteLabel.Breadcrumb", "wl_Breadcrumb");
        requireIfNeeded(".datatable", "WhiteLabel.datatables", "dataTable");
        
    });
    
    return this;
});
